<div class="form-area" id="lang-form">
    <form action="/invitation/lang_${behaviour}" method="post" id="form-lang">
    <input type="hidden" name="method" value="do"/>
    <input type="hidden" name="CSRFToken" value="${CSRFToken!""}"/>
    <table width="100%" class="dj-form-base" id="resume-lanuage-dialog-form-table">
        <colgroup>
            <col width="80">
            <col width="100">
            <col width="65">
            <col width="100">
            <col width="65">
            <col width="*">
        </colgroup>
        <tbody>
        <tr>
            <th><em>*</em>语言:</th>
            <td class="input">
                <select style="width:100px" name="lang" id="languagename-select" class="J_checkInput">
                    <option value="">请选择</option>
                    <#list dictMap.DICT_LANG.data as item>
                        <option value="${item.id?c}"<#if (resumeLang.lang)?? && resumeLang.lang==item.id> selected</#if>>${item.name}</option>
                    </#list>
                </select>
                <div style="display: none; " class="error">请选择语言名称</div>
            </td>
            <th><em>*</em>听说:</th>
            <td class="input">
                <select name="oral" style="width:100px" id="oral-select" class="J_checkInput">
                    <option value="">请选择</option>
                <#list dictMap.DICT_LANG_LEVEL.data as item>
                    <option value="${item.id?c}"<#if (resumeLang.oral)?? && resumeLang.oral==item.id> selected</#if>>${item.name}</option>
                </#list>
                </select>
                <div style="display: none; " class="error">请选择熟练程度</div>
            </td>
            <th><em>*</em>读写:</th>
            <td class="input">
                <select name="rw" style="width:100px" id="rw-select" class="J_checkInput">
                    <option value="">请选择</option>
                <#list dictMap.DICT_LANG_LEVEL.data as item>
                    <option value="${item.id?c}"<#if (resumeLang.rw)?? && resumeLang.rw==item.id> selected</#if>>${item.name}</option>
                </#list>
                </select>
                <div style="display: none; " class="error">请选择熟练程度</div>
            </td>
        </tr>
        <#if (resumeLang.langGrades)?? && resumeLang.langGrades != ''>
            <#list resumeLang.langGrades?split(',') as grade>
                <#assign gradeInfo = grade?split('|') />
                <#if grade_has_next><tr class="J_tr"><#else><tr class="last-tr J_tr"></#if>
                    <#if grade_index == 0><th>等级考试:</th><#else><th></th></#if>
                    <td class="input" colspan="5">
                        <div class="list">
                            <select name="grade"  class="exam-select">
                                <option value="">请选择</option>
                                <#if (resumeLang.lang)??>
                                    <#list dictMap.DICT_LANG.map.get(resumeLang.lang).children as item>
                                        <option value="${item.id}"<#if gradeInfo[0]?? && gradeInfo[0]!='' && item.id==gradeInfo[0]?number?int> selected</#if>>${item.name}</option>
                                    </#list>
                                </#if>
                            </select>
                            <input type="text" maxlength="5" name="score" value="${(gradeInfo[1])!}" class="text score g9" style="width:60px">
                            <label>分</label>
                            <#if grade_index !=0>
                                <a href="javascript:void(0);" class="removeme">删除</a>
                            </#if>
                        </div>
                    </td>
                </tr>
            </#list>
        <#else>
        <tr class="last-tr J_tr">
            <th>等级考试:</th>
            <td class="input" colspan="5">
                <div class="list">
                    <select name="grade"  class="exam-select">
                        <option value="">请选择</option>
                        <#if (resumeLang.lang)??>
                            <#list dictMap.DICT_LANG.map.get(resumeLang.lang).children as item>
                                <option value="${item.id}">${item.name}</option>
                            </#list>
                        </#if>
                    </select>
                    <input type="text" maxlength="5" name="score" value="${(gradeInfo[1])!}" class="text score g9" style="width:60px">
                    <label>分</label>

                </div>
            </td>
        </tr>
        </#if>
        <tr style="display:none;" class="exam J_tr">
            <th></th>
            <td class="input" colspan="5">
                <select name="grade" style="width:200px" class="exam-select">
                    <option>请选择</option>
                    <#if (resumeLang.lang)??>
                        <#list dictMap.DICT_LANG.map.get(resumeLang.lang).children as item>
                            <option value="${item.id}">${item.name}</option>
                        </#list>
                    </#if>
                </select>
                <input type="text" name="score" maxlength="5" class="text score g9" style="width:60px"> 分 <a
                    class="removeme" href="javascript:void(0);">删除</a>
            </td>
        </tr>

        <tr>
            <th></th>
            <td colspan="5"><a id="addexam-link" href="javascript:void(0);">添加一项等级考试</a></td>
        </tr>
        <tr>
            <th>&nbsp;</th>
            <td class="input button" colspan="5">
                <a href="javascript:void(0);" class="fresh formValidateSubmit margin" id="J_formSubmit" itemtype="lang"><span>保存</span></a><a href="javascript:void(0);" class="normal J_cancel" itemtype="lang"><span>取消</span></a>
            </td>
        </tr>
        </tbody>
    </table>
    </form>
    <script type="text/javascript">
        $('#languagename-select').change(function() {
            if ($('#languagename-select').val().length == 0) return;
            $.ajax({
                url: '/ajax/dict?type=lang&id=' + $(this).val(),
                success: function(r) {
                    var $select = $('#resume-lanuage-dialog-form-table .exam-select');
                    $select.find('option:gt(0)').remove();
                    var map = eval(r);
                    if (map.length == 0) {
                        $('#resume-lanuage-dialog-form-table .exam:gt(0)').hide().find('select').hide();
                        $('#resume-lanuage-dialog-form-table .tr:last').hide();
                    } else {
                        $.each(map, function() {
                            $select.append('<option value="' + this.id + '">' + this.text + '</option>');
                        });
                        $('#resume-lanuage-dialog-form-table .exam:gt(0)').show().find('select').show();
                        $('#resume-lanuage-dialog-form-table .tr:last').show();
                    }
                }
            });
        });
        $('#addexam-link').click(function() {
            $('.exam:first').clone().insertAfter($('.exam:last')).show();
            if ($('#resume-lanuage-dialog-form-table tr.exam').length >= 19) {
                $(this).hide();
            }
            return false;
        });
        $('#resume-lanuage-dialog-form-table a.removeme').live('click', function() {
            $(this).parents('.J_tr').remove();
            return false;
        });
        $('#resume-lanuage-dialog-form').submit(function() {
            $('#resume-lanuage-exam-hidden').val($('#resume-lanuage-dialog-form-table tr.exam:visible').map(
                    function() {
                        return $(this).find('.exam-select').val() + '|' + $(this).find('.score').val();
                    }).get().join(','));
        });

        $(function () {
            $('#J_langSubmit').click(function (e) {
                e.preventDefault();
                var itemType = $(this).attr('itemtype');
                formSubmit($('#form-lang'),itemType)
            });
        });
    </script>


</div>